home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_31 / gtsr.asm < prev    next >
Assembly Source File  |  1995-01-01  |  9KB  |  379 lines

  1. ;                GTSR v1.10
  2. ;         By Joshua C. Jensen (CyberStrike of Renaissance)
  3. ;             Copyright (C) 1992,1993
  4. ;═══════════════════════════════════════════════════════════════════════════════
  5.  
  6. ideal
  7. P286
  8. model    Huge
  9. jumps
  10.  
  11. stack    1024
  12.  
  13. include "gusmod.inc"
  14.  
  15. segment MyCode
  16.  
  17.         assume    cs:MyCode,ds:MyData
  18.  
  19. MMus        SMus    <>
  20. P               PM      <>
  21. MusBuf        dw    0
  22. Music           dw      0,BlankMusicSeg
  23. Mode        db    0        ; 0 - Text
  24.                     ; 1 - Graphics
  25. PanPos        db    3,12,12,3
  26. MaxVol        db    100
  27. ChanVol     db    100,100,100,100
  28. PlayStat    db    0
  29.  
  30. ConfigFile    db    'GTSR.INF',0
  31. GConfigFile    db    'GSETUP.CFG',0
  32.  
  33. include         "sd.asm"
  34. include     "env.asm"
  35. include     "cmdline.asm"
  36. include     "modload.asm"
  37.  
  38. proc        GetInfo near
  39.                 mov     bx,9
  40.                 mov     cx,1
  41.                 mov     si,seg MMus
  42.                 mov     di,offset MMus
  43.                 call    [dword cs:Music]
  44.                 ret
  45. endp            GetInfo
  46.  
  47. proc            SetInfo near
  48.                 mov     bx,0Ah
  49.                 mov     si,seg MMus
  50.                 mov     di,offset MMus
  51.                 call    [dword cs:Music]
  52.                 ret
  53. endp            SetInfo
  54.  
  55. proc        Terminate far
  56.         mov    bx,5
  57.         call    [dword ptr cs:Music]
  58.         mov    bx,1        ; Close down player.
  59.         call    [dword ptr cs:Music]
  60.         ret
  61. endp            Terminate
  62.  
  63. proc        Error near
  64.                 mov     ax,MyData
  65.         mov    ds,ax
  66.         mov    ah,9
  67.                 int     21h
  68.         call    Terminate
  69.         mov    ax,4C00h
  70.         int    21h
  71. endp            Error
  72.  
  73. ; si - Filename offset
  74. proc            PutName
  75.         push    ds es
  76.         mov    ax,MyData
  77.                 mov     es,ax
  78.         mov    di,[es:PutFilename]
  79.         mov    ax,cs
  80.                 mov     ds,ax
  81.                 mov     cx,12
  82.         rep    movsb
  83.         mov    al,0
  84.         stosb
  85.         pop    es ds
  86.         ret
  87. endp            PutName
  88.  
  89. proc        ReadGConfig
  90.         push    ds
  91.         mov    ax,MyData
  92.         mov    ds,ax
  93.         mov    si,offset GConfigFile
  94.         call    PutName
  95.         mov    dx,offset GDirectory
  96.                 mov     cx,seg GDirectory
  97.         mov    ds,cx
  98.         mov    ax,3D00h
  99.         int    21h
  100.         jb    @@NoFind
  101.         mov    bx,ax
  102.         mov    cx,11
  103.         mov    ax,cs
  104.         mov    ds,ax
  105.         mov    dx,offset GUSPort
  106.         mov    ah,3Fh
  107.                 int     21h
  108.         mov    ah,3Eh
  109.                 int     21h
  110.         pop    ds
  111.         ret
  112. @@NoFind:    mov    dx,offset NoGCFound
  113.         call    Error
  114.         pop    ds
  115.         ret
  116. endp        ReadGConfig
  117.  
  118. proc            ReadConfig
  119.         push    ds
  120.         mov    ax,MyData
  121.         mov    ds,ax
  122.         mov    si,offset ConfigFile
  123.         call    PutName
  124.         mov    dx,offset GDirectory
  125.                 mov     cx,seg GDirectory
  126.         mov    ds,cx
  127.         mov    ax,3D00h
  128.         int    21h
  129.         jb    @@SetInfo
  130.         mov    bx,ax
  131.         mov    cx,11
  132.         mov    ax,cs
  133.         mov    ds,ax
  134.         mov    dx,offset Mode
  135.         mov    ah,3Fh
  136.                 int     21h
  137.         mov    ah,3Eh
  138.                 int     21h
  139. @@SetInfo:    call    GetInfo
  140.         mov    al,[cs:MaxVol]
  141.                 mov     [cs:offset MMus+(offset (SMus).MaxVolume)],al
  142.         mov    al,[cs:PlayStat]
  143.         mov    [cs:offset MMus+(offset (SMus).PlayStatus)],al
  144. @@Setit:        mov     cx,00000011b
  145.         call    SetInfo
  146.                 cli
  147.         les    di,[cs:offset MMus+(offset (SMus).ChannelLoc)]
  148.         mov    bx,0
  149. @@CopyLoop:    mov    al,[cs:bx+PanPos]
  150.         mov    [es:di+MS.sc_PanPosition],al
  151.         mov    al,[cs:bx+ChanVol]
  152.         mov    [es:di+MS.MasterVolume],al
  153.         add    di,size MS
  154.         inc    bx
  155.         cmp    bx,4
  156.         jnz    @@CopyLoop
  157.         sti
  158. @@NoFind:       pop     ds
  159.         ret
  160. endp            ReadConfig
  161.  
  162. proc            InstallProg
  163.         push    ds
  164.         mov    ax,GUSSeg
  165.         mov    es,ax
  166.         xor    di,di
  167.         mov    ax,0000h
  168.         mov    ds,ax
  169.         mov    si,80*4
  170.         add    di,uOldInt
  171.         cli
  172.         mov    bx,[ds:si]
  173.         mov    cx,[ds:si+2]
  174.         mov    [es:di],bx
  175.         mov    [es:di+2],cx
  176.         sti
  177.         sub    di,uOldInt
  178.         add    di,uTerm
  179.         mov    bx,offset Terminate
  180.         mov    cx,cs
  181.         mov    [es:di],bx
  182.                 mov     [es:di+2],cx
  183.         sub    di,uTerm
  184.         add    di,uPsp
  185.         mov    bx,[cs:PspAddress]
  186.         mov    [es:di],bx
  187.         mov    bx,0
  188.         mov    cx,GUSSeg
  189.         cli
  190.         mov    [ds:si],bx
  191.         mov    [ds:si+2],cx
  192.         sti
  193.         mov    ds,[cs:PspAddress]
  194.         mov    bx,2Ch
  195.         mov    es,[bx]
  196.         mov    ah,49h
  197.                 int     21h
  198.                 pop     ds
  199.         ret
  200. endp            InstallProg
  201.  
  202. proc            DetectOld
  203.         mov    ax,0000h
  204.         mov    es,ax
  205.         mov    di,80*4
  206.         cli
  207.         mov    ax,[es:di]
  208.         mov    es,[es:di+2]
  209.         mov    di,ax
  210.         sti
  211.         add    di,uDetect
  212.         cmp    [Word es:di],'TG'
  213.         jnz    @@NotThere
  214.         cmp    [Word es:di+2],'RS'
  215.         jnz    @@NotThere
  216.         sub    di,uDetect
  217.         add    di,uTerm
  218.         push    ds es di
  219.                 call    [dword ptr es:di]       ; Call the terminate function.
  220.         pop    di es ds
  221.                 mov     ah,49h                  ; Should have cleared it.
  222.         mov    es,[Word es:di+4]
  223.         int    21h
  224.         sub    di,uTerm
  225.         add    di,uOldInt
  226.         mov    bx,[es:di]
  227.         mov    cx,[es:di+2]
  228.         mov    ax,0000h
  229.         mov    es,ax
  230.         mov    di,80*4
  231.         cli
  232.         mov    [es:di],bx
  233.         mov    [es:di+2],cx
  234.                 sti
  235. @@NotThere:    ret
  236. endp            DetectOld
  237.  
  238. assume          ds:MyData
  239.  
  240. PspAddress    dw    ?
  241. SizeOfProg      dw      ?
  242. TopOfData    dw    ?
  243.  
  244. proc        Main
  245. Start:          mov     [cs:PspAddress],es
  246.                 mov     ax,zzzzzseg
  247.                 inc     ax
  248.                 mov     [cs:TopOfData],ax
  249. ;         mov     [cs:PspAddress],es
  250. ;         mov     ax,es
  251. ;         mov     bx,zzzzzseg
  252. ;         sub     bx,ax
  253. ;         add     bx,2
  254. ;         mov     [cs:SizeOfProg],bx
  255. ;         mov     ah, 4ah
  256. ;         int     21h
  257.  
  258.         mov    ax,MyData
  259.         mov    ds,ax
  260.         mov    ah,9
  261.         mov    dx,offset GTSRTitle
  262.                 int     21h
  263.  
  264.         call    DetectOld
  265.         call    SetEnv
  266. @@LoadDriver:    mov    si,offset SoundFile
  267.         call    PutName
  268.         mov    dx,offset GDirectory
  269.         mov    cx,seg GDirectory
  270.                 call    LoadSoundDriver
  271.         jnb    @@DriverLoaded
  272.         mov    dx,offset NoDriverFound
  273.                 call    Error
  274. @@DriverLoaded: call    ReadGConfig
  275.         mov    ax,[cs:GUSIRQ]
  276.                 mov     bx,0
  277.         mov    cx,[cs:GUSMIDI]
  278.         mov    dx,[cs:GUSPort]
  279.         mov    si,[cs:DMAIn]
  280.                 mov     di,[cs:DMAOut]
  281.                 call    [dword ptr cs:Music]
  282.                 jnb     @@FoundCard
  283.         mov    dx,offset NoGUS
  284.         call    Error
  285. @@FoundCard:    mov    [cs:GUSIRQ],si
  286.                 mov     [cs:GUSPort],di
  287.         call    LoadCommandLine
  288.         jnb    @@ThereWasOne
  289.         mov    dx,offset UninstalledMsg
  290.         call    Error
  291.  
  292. @@ThereWasOne:    mov    ax,[cs:TopOfData]
  293.         mov    [cs:MusBuf],ax
  294.                 add     [Word cs:TopOfData],4096/16
  295.                 ; Load the module.
  296.         mov    cx,ds
  297.         mov    dx,130
  298.         call    MUS_LoadModule
  299.                 jb      @@nofile
  300.         jmp    @@BeginPlay
  301.  
  302. @@noargv:    mov    dx,offset NoFileName
  303.         call    Error
  304. @@nofile:    mov    dx,offset NoFileFound
  305.         call    Error
  306. @@BeginPlay:    mov    si,offset ConfigFile
  307.         call    ReadConfig
  308.  
  309.         mov    [Word cs:offset P+(offset (PM).MusBuf)],0
  310.         mov    ax,[cs:MusBuf]
  311.                 mov     [Word cs:offset P+(offset (PM).MusBuf)+2],ax
  312.         mov    [Word cs:offset P+(offset (PM).Header)],offset PS16Header
  313.         mov    [Word cs:offset P+(offset (PM).Header)+2],cs
  314.         mov    [Word cs:offset P+(offset (PM).PatternLoc)],offset PatternLoc
  315.         mov    [Word cs:offset P+(offset (PM).PatternLoc)+2],cs
  316.         mov    [Word cs:offset P+(offset (PM).InsLoc)],offset InsLoc
  317.         mov    [Word cs:offset P+(offset (PM).InsLoc)+2],cs
  318.         mov    [Word cs:offset P+(offset (PM).mt_speed)],6
  319.         mov    [Word cs:offset P+(offset (PM).mt_counter)],5
  320.         mov    [Word cs:offset P+(offset (PM).mt_PatternPos)],0
  321.                 mov     [Word cs:offset P+(offset (PM).mt_SongPos)],0
  322.         mov    cx,cs
  323.         mov    si,offset P
  324.         mov    bx,4
  325.                 call    [dword cs:Music]
  326.  
  327. @@Exit:     call    InstallProg
  328.         mov    ax,[cs:PspAddress]
  329.         mov    es,ax
  330.         mov    dx,[cs:TopOfData]
  331.         sub    dx,ax
  332.         add    dx,2
  333.         mov    ah,31h
  334.         int    21h
  335. endp        Main
  336.  
  337. ends        MyCode
  338.  
  339. segment     GUSSeg
  340. GStart        = $
  341.         jmp    [dword cs:OldInt]
  342. uDetect     = $-GStart
  343. GUSDetect       db      'GTSR'
  344. uOldInt     = $-GStart
  345. OldInt          dd      0
  346. uTerm        = $-GStart
  347. TerminateProc   dd      0
  348. uPsp        = $-GStart
  349. PspAddr     dw    0
  350. ends            GUSSeg
  351.  
  352. segment     BlankMusicSeg
  353.         stc
  354.         retf
  355. ends        BlankMusicSeg
  356.  
  357. segment MyData
  358. GTSRTitle    db    'GTSR v1.11 By Joshua C. Jensen (CyberStrike of Renaissance)',13,10,'$'
  359. NoGUS           db      '1: Could not detect a Gravis UltraSound card.',13,10,'$'
  360. NoFileName      db      '2: Usage: GTSR filename<.mod>',13,10,'$'
  361. NoFileFound     db      '3: Module not found.',13,10,'$'
  362. NoGCFound    db    '4: GSETUP.CFG not found.  Run SETUP.',13,10,'$'
  363. NoEnvFound      db      '5: The environment variable GUSMOD was not found.',13,10,'$'
  364. IllegalEnv      db      '6: Illegal environment variable.',13,10,'$'
  365. NoDriverFound   db      '7: Sound driver not found.',13,10,'$'
  366. UninstalledMsg  db      'Uninstalled from memory.',13,10,'$'
  367.  
  368. GDirectory    db    120 dup (0)
  369. GEnv        db    6,"GUSMOD"
  370. PutFilename    dw    0
  371. ends    MyData
  372.  
  373. segment zzzzzseg
  374.     db    16 dup (?)
  375. ends    zzzzzseg
  376.  
  377.         end     Start
  378.  
  379.